// import type { UserInfo } from '@vben/types';

import { requestClient } from '#/api/request';

export namespace UserApi {
  export interface Meta {
    title: string;
    icon: string;
    noCache: boolean;
    link: null;
  }
  export interface Child {
    name: string;
    path: string;
    hidden: boolean;
    component: string;
    meta: Meta;
  }
  export interface Datum {
    name: string;
    path: string;
    hidden: boolean;
    redirect: string;
    component: string;
    alwaysShow: boolean;
    meta: Meta;
    children: Child[];
  }
  export interface GetUserRoutesResult {
    msg: string;
    code: number;
    data: Datum[];
  }
  export interface Role {
    searchValue: null;
    createBy: null;
    createTime: null;
    updateBy: null;
    updateTime: null;
    remark: null;
    // eslint-disable-next-line no-use-before-define
    params: Params;
    roleId: number;
    roleName: string;
    roleKey: string;
    roleSort: string;
    dataScope: string;
    menuCheckStrictly: boolean;
    deptCheckStrictly: boolean;
    status: string;
    delFlag: null;
    flag: boolean;
    menuIds: null;
    deptIds: null;
    admin: boolean;
  }
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
  export interface Params {}
  export interface Dept {
    searchValue: null;
    createBy: null;
    createTime: null;
    updateBy: null;
    updateTime: null;
    remark: null;
    params: Params;
    deptId: number;
    parentId: number;
    ancestors: null;
    deptCode: null;
    deptName: string;
    orderNum: string;
    leader: string;
    phone: null;
    email: null;
    status: string;
    delFlag: null;
    parentName: null;
    children: any[];
  }
  export interface User {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: null;
    updateTime: null;
    remark: string;
    params: Params;
    userId: number;
    deptId: number;
    userName: string;
    nickName: string;
    email: string;
    phonenumber: string;
    sex: string;
    avatar: string;
    salt: null;
    status: string;
    delFlag: string;
    loginIp: string;
    loginDate: Date;
    dept: Dept;
    roles: Role[];
    roleIds: null;
    postIds: null;
    roleId: null;
    admin: boolean;
  }
  export interface UserInfoResult {
    msg: string;
    code: number;
    permissions: string[];
    roles: string[];
    user: User;
  }
}

/**
 * 获取用户信息
 */
export async function getUserInfoApi() {
  return requestClient.get<UserApi.UserInfoResult>('/getInfo');
}

// 获取路由
export async function getUserRoutersApi() {
  return requestClient.get<UserApi.GetUserRoutesResult>('/getRouters');
}
